# Importing Data
THAILAND<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Rubber/Rubber.xlsx",sheet = "Sheet1", range = "i1:i325")

# Checking the Imported Data
View(THAILAND)
# Creating Time Series Data
THAILAND_ts <- ts(THAILAND, start=c(1991,1), end=c(2017,12), frequency=12)
# Viewing and Checking the Created Time Series Data
THAILAND_ts
sum(is.na(THAILAND_ts))
library(forecast)
THAILAND_ts <- tsclean(THAILAND_ts)
THAILAND_ts

# Identification: Plotting the Time Series Data
plot(THAILAND_ts)

# Estimating the appropriate model
THAILAND_ts_model <- auto.arima(THAILAND_ts)
THAILAND_ts_model

# Forecasting
options(max.print=1000000)
THAILAND_ts_forecast <- forecast (THAILAND_ts_model, level=c(95), h=276)
plot(THAILAND_ts_forecast)
THAILAND_ts_forecast             

# Exporting
write.table(THAILAND_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Rubber/THAILAND_TSA.csv", sep=",")


